package com.uphone.kingmall.activity.personal;

import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.china.zhuoyue.R;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.uphone.kingmall.adapter.AttentionStoreAdapter;
import com.uphone.kingmall.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * <pre>
 *     author : 王雨
 *     e-mail :
 *     time   : 2018/07/31
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class SearchAttentShopActivity extends BaseActivity {
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.rv_rv_attent_list)
    RecyclerView rvRvAttentList;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;
    @BindView(R.id.et_content)
    EditText etContent;

    @Override
    public int getLayoutContentId() {
        return R.layout.kingmall_activity_search_shop;
    }

    @Override
    public void initView() {
        setStatusBar();
        List list = new ArrayList();
        for (int i = 0; i < 4; i++) {
            list.add("");
        }
        rvRvAttentList.setLayoutManager(new LinearLayoutManager(this));
        AttentionStoreAdapter adapter = new AttentionStoreAdapter();
        rvRvAttentList.setAdapter(adapter);
    }

    @Override
    public void initData() {
        etContent.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                /*判断是否是“搜索”键*/
                if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                    String key = etContent.getText().toString().trim();
                    if (TextUtils.isEmpty(key)) {
                        showShortToast("搜索内容不能为空");
                        return true;
                    }
                    //隐藏键盘
                    ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
                            .hideSoftInputFromWindow(SearchAttentShopActivity.this.getCurrentFocus()
                                    .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
                    return true;
                }
                return false;
            }
        });
    }


    @OnClick(R.id.iv_back)
    public void onViewClicked() {
        onBackPressed();
    }
}
